package leetcode.code1015;

import java.util.HashSet;
import java.util.Set;

public class Solution {

	public int smallestRepunitDivByK(int k) {
		Set<Integer> set = new HashSet<>();
		int ans = 1, num = 1;
		while (set.add(num) && (num = num % k) != 0) {
			ans++;
			num = num * 10 + 1;
		}
		return num % k == 0 ? ans : -1;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		System.out.println(so.smallestRepunitDivByK(13));
	}

}
